package cn.yuhh.service.impl;

import cn.yuhh.dao.IFoodDao;
import cn.yuhh.entity.Food;
import cn.yuhh.factory.BeanFactory;
import cn.yuhh.service.IFoodService;
import org.junit.Test;

import java.util.List;

/**
 * Created by Brill on 2016/12/5.
 */
public class FoodService implements IFoodService {

    IFoodDao dao = BeanFactory.getInstance("foodDao", IFoodDao.class);
    @Override
    public void add(Food food) {
        dao.add(food);
    }

    @Override
    public void delete(int id) {
        dao.delete(id);
    }

    @Override
    public void update(Food food) {
        dao.update(food);
    }

    @Override
    public List<Food> query() {
        return dao.query();
    }

    @Override
    public Food findById(int id) {
        return dao.findById(id);
    }

    @Override
    public Food query(String keyword) {
        return dao.query(keyword);
    }

    @Override
    public List<Food> findByType(int type) {
        return dao.findByType(type);
    }

    @Test
    public void testQuery() {
        List<Food> foods = query();
        for (Food food :
                foods) {
            System.out.println(food);
        }
    }
}
